/*
 * @Author: Wang WeiHao
 * @Date: 2024-01-11 17:58:03
 * @LastEditors: Wang WeiHao
 * @LastEditTime: 2024-03-11 16:53:23
 * @Description:
 * @FilePath: \hmcs_map\vite.config.js
 */

import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import {
  ElementPlusResolver,
  VueUseComponentsResolver,
} from "unplugin-vue-components/resolvers";
import path from "path";
// https://vitejs.dev/config/
export default defineConfig({
  //基本路径
  base: "./",
  build: {
    outDir: "dist",
    sourcemap: false,
    assetsDir: "assets",
  },
  css: {
    devSourcemap: false,
  },
  plugins: [
    vue(),
    AutoImport({
      imports: ["vue"],
      dirs: ["src/hook"],
      // 第三方组件库的解析器
      dts: "./auto-imports.d.ts",
    }),

    Components({
      dts: "./components.d.ts",
      extensions: ["vue", "md"],
      resolvers: [],
    }),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  server: {
    host: " 192.168.188.166",
    // host: 'localhost',

    port: 80,
    proxy: {
      "/api": {
        target: "http://113.57.78.20:38029/hmcs",
        // target: 'http://192.168.1.4:8081/',
        changeOrigin: true,
        secure: false,
        ws: false,
        rewrite: (path) => {
          return path.replace(/^\/api/, "");
        },
      },
      "/gl": {
        target: "http://www.hycim.com",
        // target: 'http://192.168.1.4:8081/',
        changeOrigin: true,
        secure: false,
        ws: false,
        rewrite: (path) => {
          return path.replace(/^\/gl/, "");
        },
      },
      // '/images': {
      //     target: 'http://127.0.0.1:8097/',
      //     changeOrigin: true,
      //     secure: false,
      //     ws: false,
      //     rewrite: (path) => {
      //         return path.replace(/^\/images/, '');
      //     }
      // },
      // '/mp4': {
      //     target: 'http://digital-prospecting-dev.oss-cn-hangzhou.aliyuncs.com',
      //     changeOrigin: true,
      //     secure: false,
      //     ws: false,
      //     rewrite: (path) => {
      //         return path.replace(/^\/mp4/, '');
      //     }
      // }
    },
    open: false,
    https: false,
  },
  preview: {
    host: "127.0.0.1",
    port: 8099,
    open: false,
    https: false,
  },
});
